﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_DownloadFileType.cs
文件名称：DownloadFileType.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/21
作　　者：
内容摘要：表[DownLoad_File_Type]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.DownLoadMgnt
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：DownloadFileType
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class DownloadFileType : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is DownloadFileType)
				{
					if (obj == this)
						return true;
					DownloadFileType castObj = (DownloadFileType)obj; 
					
					if (!this.m_DownloadFileTypeId.Equals(castObj.DownloadFileTypeId))
						return false;
						
					if (!this.m_TypeName.Equals(castObj.TypeName))
						return false;
						
					if (!this.m_Desc.Equals(castObj.Desc))
						return false;
						
					if (!this.m_Createby.Equals(castObj.Createby))
						return false;
						
					if (!this.m_Createdate.Equals(castObj.Createdate))
						return false;
						
					if (!this.m_Lcid.Equals(castObj.Lcid))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_DownloadFileTypeId != null)
					{
						hash = hash ^ m_DownloadFileTypeId.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_TypeName != null)
					{
						hash = hash ^ m_TypeName.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Desc != null)
					{
						hash = hash ^ m_Desc.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createby != null)
					{
						hash = hash ^ m_Createby.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createdate != null)
					{
						hash = hash ^ m_Createdate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Lcid != null)
					{
						hash = hash ^ m_Lcid.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public DownloadFileType()
			{
				MarkNew();
			}						
			
			public DownloadFileType GetOldValue()
			{
				return OldValue as DownloadFileType;
			}
		
		#region DownloadFileTypeId属性
			private int m_DownloadFileTypeId = 0;
			/// <summary>
			/// 属性名称： DownloadFileTypeId
			/// 内容摘要： DB列名：DownLoad_File_Type_ID[类型ID]
			///            DB类型：int
			/// </summary>
			public int DownloadFileTypeId
			{
				get
					{
						return m_DownloadFileTypeId;
					}
				set
					{
						if (m_DownloadFileTypeId as object == null || !m_DownloadFileTypeId.Equals(value))
						{
							m_DownloadFileTypeId = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region TypeName属性
			private string m_TypeName = String.Empty;
			/// <summary>
			/// 属性名称： TypeName
			/// 内容摘要： DB列名：Type_Name[类型名]
			///            DB类型：string
			/// </summary>
			public string TypeName
			{
				get
					{
						return m_TypeName;
					}
				set
					{
						if (m_TypeName as object == null || !m_TypeName.Equals(value))
						{
							m_TypeName = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Desc属性
			private string m_Desc = String.Empty;
			/// <summary>
			/// 属性名称： Desc
			/// 内容摘要： DB列名：Desc[描述]
			///            DB类型：string
			/// </summary>
			public string Desc
			{
				get
					{
						return m_Desc;
					}
				set
					{
						if (m_Desc as object == null || !m_Desc.Equals(value))
						{
							m_Desc = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createby属性
			private string m_Createby = String.Empty;
			/// <summary>
			/// 属性名称： Createby
			/// 内容摘要： DB列名：CreateBy[创建人]
			///            DB类型：string
			/// </summary>
			public string Createby
			{
				get
					{
						return m_Createby;
					}
				set
					{
						if (m_Createby as object == null || !m_Createby.Equals(value))
						{
							m_Createby = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createdate属性
			private DateTime m_Createdate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： Createdate
			/// 内容摘要： DB列名：CreateDate[创建时间]
			///            DB类型：DateTime
			/// </summary>
			public DateTime Createdate
			{
				get
					{
						return DateTime.Parse(m_Createdate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_Createdate as object == null || !m_Createdate.Equals(value))
						{
							m_Createdate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Lcid属性
			private int m_Lcid = 0;
			/// <summary>
			/// 属性名称： Lcid
			/// 内容摘要： DB列名：Lcid[语言环境]
			///            DB类型：int
			/// </summary>
			public int Lcid
			{
				get
					{
						return m_Lcid;
					}
				set
					{
						if (m_Lcid as object == null || !m_Lcid.Equals(value))
						{
							m_Lcid = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("DownLoad_File_Type_ID",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Type_Name",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Desc",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateBy",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Lcid",typeof(int)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("DownloadFileTypeId",typeof(int)));
					dtResult.Columns.Add(new DataColumn("TypeName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Desc",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Createby",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Createdate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Lcid",typeof(int)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["DownLoad_File_Type_ID"] = this.DownloadFileTypeId;
					dr["Type_Name"] = this.TypeName;
					dr["Desc"] = this.Desc;
					dr["CreateBy"] = this.Createby;
					dr["CreateDate"] = this.Createdate;
					dr["Lcid"] = this.Lcid;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["DownloadFileTypeId"] = this.DownloadFileTypeId;
					dr["TypeName"] = this.TypeName;
					dr["Desc"] = this.Desc;
					dr["Createby"] = this.Createby;
					dr["Createdate"] = this.Createdate;
					dr["Lcid"] = this.Lcid;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成DownloadFileType对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>DownloadFileType对象</returns>
			public static DownloadFileType Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				DownloadFileType obj = new DownloadFileType();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.DownloadFileTypeId = (dr["DownLoad_File_Type_ID"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["DownLoad_File_Type_ID"],typeof(int));
					obj.TypeName = (dr["Type_Name"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Type_Name"],typeof(string));
					obj.Desc = (dr["Desc"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Desc"],typeof(string));
					obj.Createby = (dr["CreateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CreateBy"],typeof(string));
					obj.Createdate = (dr["CreateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDate"],typeof(DateTime));
					obj.Lcid = (dr["Lcid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Lcid"],typeof(int));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.DownloadFileTypeId = (dr["DownloadFileTypeId"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["DownloadFileTypeId"],typeof(int));
					obj.TypeName = (dr["TypeName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["TypeName"],typeof(string));
					obj.Desc = (dr["Desc"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Desc"],typeof(string));
					obj.Createby = (dr["Createby"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Createby"],typeof(string));
					obj.Createdate = (dr["Createdate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Createdate"],typeof(DateTime));
					obj.Lcid = (dr["Lcid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Lcid"],typeof(int));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成DownloadFileType对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>DownloadFileType对象</returns>
			public static DownloadFileType Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的DownloadFileType对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>DownloadFileType对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的DownloadFileType对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>DownloadFileType对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的DownloadFileType对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">DownloadFileType对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(DownloadFileType obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的DownloadFileType对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">DownloadFileType对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			DownloadFileType old = this.OldValue as DownloadFileType;
			if (old != null)
			{
					this.DownloadFileTypeId = old.DownloadFileTypeId;
					this.TypeName = old.TypeName;
					this.Desc = old.Desc;
					this.Createby = old.Createby;
					this.Createdate = old.Createdate;
					this.Lcid = old.Lcid;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region DownloadFileType实体的内部Key类
			/// <summary>
			/// DownloadFileType实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_DownloadFileTypeId;
				public int DownloadFileTypeId
				{
 					get 
					{ 
						 return m_DownloadFileTypeId; 
					}
					set 
					{ 
						m_DownloadFileTypeId = value;
					}
				}
		
				public Key(int pDownloadFileTypeId)
				{
					m_DownloadFileTypeId=pDownloadFileTypeId;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体DownloadFileType的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(DownloadFileTypeId);				
			}
			
				
		#endregion
	}
}
